#include <qwt_plot.h>
#include <qwt_interval.h>
#include <qwt_system_clock.h>

#include <QTime>
#include <QDebug>

class QwtPlotCurve;
class QwtPlotMarker;
class QwtPlotDirectPainter;

class Plot: public QwtPlot
{
    Q_OBJECT

public:
    Plot(QWidget * = NULL);
    virtual ~Plot();

    void start();
    void stop();
    virtual void replot();

    double getTimeFromMidnight();

public Q_SLOTS:
    void setIntervalLength(double);
    double getIntervalLength();
    void setTSet(double);
    double getTSet();
    void setTRange(double);
    double getTRange();

protected:
    virtual void showEvent(QShowEvent *);
    virtual void resizeEvent(QResizeEvent *);
    virtual void timerEvent(QTimerEvent *);

private:
    void initGradient();

    void updateCurve();
    void incrementInterval();

    QwtPlotMarker *c_max;
    QwtPlotMarker *c_min;
    QwtPlotCurve *d_curve;
    int d_paintedPoints;

    QwtPlotDirectPainter *d_directPainter;

    QwtInterval d_interval;
    int d_timerId;

    //QwtdSystemClock d_clock;
    QTime d_clock;

    //QTime currentTime;

    double tSet, tRange;//, tmax, tmin;

};
